package com.sikaryofficial.backend.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author : qinjinyuan
 * @desc : TODO  请填写你的功能描述
 * @date : 2024/11/21 14:29
 */
@Getter
@AllArgsConstructor
public enum PointOptEnum {

    ADD(0, "Add"),
    REDUCE(1, "Reduce");

    private final Integer code;

    private final String descEn;

    public static PointOptEnum getByCode(Integer code) {
        return Arrays.stream(PointOptEnum.values())
                .filter(channelEnum -> channelEnum.getCode().equals(code))
                .findFirst().orElse(null);
    }

    public static String getDescByCode(Integer code) {
        PointOptEnum codeObject = getByCode(code);
        if (codeObject == null) {
            return "-";
        }
        return Optional.ofNullable(codeObject.getDescEn()).orElse("-");
    }
}
